package com.pbase.data.networkmanage;

import androidx.annotation.NonNull;
import androidx.lifecycle.DefaultLifecycleObserver;
import androidx.lifecycle.LifecycleOwner;

public class NetWorkManage implements DefaultLifecycleObserver {
    private static NetWorkManage myself;
    private NetWorkConnection mNetWorkConnection;

    private NetWorkManage() {
        mNetWorkConnection = new NetWorkConnection();
    }

    public static NetWorkManage getInstance() {
        if (myself == null) {
            synchronized (NetWorkManage.class) {
                if (myself == null) {
                    myself = new NetWorkManage();
                }
            }
        }
        return myself;
    }

    public void setNetWorkConnectionListsener(
                                                       NetWorkConnection.NetWorkConnectionListsener listsener) {
        mNetWorkConnection.setNetWorkConnectionListsener(  listsener);
    }

    @Override
    public void onResume(@NonNull LifecycleOwner owner) {
        mNetWorkConnection.register();
    }

    @Override
    public void onPause(@NonNull LifecycleOwner owner) {
        mNetWorkConnection.unregister();
    }


}
